package com.ruoyi.property.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.property.domain.ReportFeeSummaryInfo;
import com.ruoyi.property.service.IReportFeeSummaryInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 费用汇总表Controller
 * 
 * @author sux
 * @date 2021-06-30
 */
@Controller
@RequestMapping("/property/reportFeeSummaryInfo")
public class ReportFeeSummaryInfoController extends BaseController
{
    private String prefix = "property/reportFeeSummaryInfo";

    @Autowired
    private IReportFeeSummaryInfoService reportFeeSummaryInfoService;

    @RequiresPermissions("property:reportFeeSummaryInfo:view")
    @GetMapping()
    public String reportFeeSummaryInfo()
    {
        return prefix + "/reportFeeSummaryInfo";
    }

    /**
     * 查询费用汇总表列表
     */
    @RequiresPermissions("property:reportFeeSummaryInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ReportFeeSummaryInfo reportFeeSummaryInfo)
    {
        startPage();
        List<ReportFeeSummaryInfo> list = reportFeeSummaryInfoService.selectReportFeeSummaryInfoList(reportFeeSummaryInfo);
        return getDataTable(list);
    }

    /**
     * 导出费用汇总表列表
     */
    @RequiresPermissions("property:reportFeeSummaryInfo:export")
    @Log(title = "费用汇总表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ReportFeeSummaryInfo reportFeeSummaryInfo)
    {
        List<ReportFeeSummaryInfo> list = reportFeeSummaryInfoService.selectReportFeeSummaryInfoList(reportFeeSummaryInfo);
        ExcelUtil<ReportFeeSummaryInfo> util = new ExcelUtil<ReportFeeSummaryInfo>(ReportFeeSummaryInfo.class);
        return util.exportExcel(list, "reportFeeSummaryInfo");
    }

    /**
     * 新增费用汇总表
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存费用汇总表
     */
    @RequiresPermissions("property:reportFeeSummaryInfo:add")
    @Log(title = "费用汇总表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ReportFeeSummaryInfo reportFeeSummaryInfo)
    {
        return toAjax(reportFeeSummaryInfoService.insertReportFeeSummaryInfo(reportFeeSummaryInfo));
    }

    /**
     * 修改费用汇总表
     */
    @GetMapping("/edit/{configId}")
    public String edit(@PathVariable("configId") Long configId, ModelMap mmap)
    {
        ReportFeeSummaryInfo reportFeeSummaryInfo = reportFeeSummaryInfoService.selectReportFeeSummaryInfoById(configId);
        mmap.put("reportFeeSummaryInfo", reportFeeSummaryInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存费用汇总表
     */
    @RequiresPermissions("property:reportFeeSummaryInfo:edit")
    @Log(title = "费用汇总表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ReportFeeSummaryInfo reportFeeSummaryInfo)
    {
        return toAjax(reportFeeSummaryInfoService.updateReportFeeSummaryInfo(reportFeeSummaryInfo));
    }

    /**
     * 删除费用汇总表
     */
    @RequiresPermissions("property:reportFeeSummaryInfo:remove")
    @Log(title = "费用汇总表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(reportFeeSummaryInfoService.deleteReportFeeSummaryInfoByIds(ids));
    }
}
